package com.young.core.manager;

import com.young.core.domain.JobDO;
import com.young.common.query.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * name: JobInfoManager
 *
 * @author zhaoxinbo
 * @Description
 * @Date create in 2020/9/21 17:19.
 */
public interface JobManager {

    @Transactional
    void insert(JobDO job);

    @Transactional
    void update(JobDO job);

    /**
     * 根据id获取任务信息
     *
     * @param id
     * @return
     */
    JobDO get(int id);

    JobDO getCache(int id) throws ExecutionException;

    JobDO getCache(String uniqueCode) throws ExecutionException;

    JobDO get(String uniqueCode);

    boolean exist(String uniqueCode);

    @Transactional
    void delete(int id);

    /**
     * 批量修改任务,
     * <p>
     *     可选项:
     *     1. group
     *     2. job_run_node
     *     必须项:
     *     operator
     *     update_time
     * </p>
     * @param project
     */
    @Transactional
    void batchUpdate(String project, Collection<Integer> ids, Map<String, Object> fields);

    Pagination<JobDO> query(Query query);

    @Transactional
    void updateStatus(int id, String project, int status, String operator);

    int count(String project);

    List<JobDO> getAll(String project);
}
